package ru.msu.cmc.sp.oberon2;

public class BuiltInTypeSymbol extends Symbol implements Type {
    int typeIndex;
    public BuiltInTypeSymbol(String name, int typeIndex) {
        super(name);
        this.typeIndex = typeIndex;
    }
    public int getTypeIndex() { return typeIndex; }
    public String toString() { return getName(); }   
    public boolean isNumber() 
    {
    	if (typeIndex >= SymbolTable.tSHORTINT && typeIndex <= SymbolTable.tLONGREAL) return true;
    	else return false;
    }
    
    public boolean isInt() 
    {
    	if (typeIndex >= SymbolTable.tSHORTINT && typeIndex <= SymbolTable.tLONGINT) return true;
    	else return false;
    }
    public boolean isReal(){
    	return (isNumber() && !isInt());
    }
    public boolean isString() {
    	return false;
    }
    public boolean equals(Object obj) 
    {
    	if (obj instanceof Type) {
    		if (((Type)obj).getTypeIndex() == this.getTypeIndex() ||
    				((Type)obj).getName() == this.getName()) 
    			return true;
    	}
    	return false;
    }
}